package cc.ufinity.networkdiagnose.manager;

import java.io.InputStream;

import org.xmlpull.v1.XmlPullParser;

import cc.ufinity.networkdiagnose.app.GlobalApp;

import android.util.Xml;

public class UpdataInfoParser {

	/**
	 * ��pull�������������������ص�xml�ļ� (xml��װ�˰汾��)
	 */
	public static UpdateInfo getUpdataInfo(InputStream is) throws Exception{
		XmlPullParser  parser = Xml.newPullParser();  
		parser.setInput(is, "utf-8");//���ý��������Դ 
		int type = parser.getEventType();
		UpdateInfo info = null;//ʵ��
		while(type != XmlPullParser.END_DOCUMENT ){
			switch (type) {
			case XmlPullParser.START_DOCUMENT:  
                break;
			case XmlPullParser.START_TAG:
				String tag = parser.getName();
				if("apinfo".equals(tag)) {
					info = new UpdateInfo();
				} else if("version".equals(tag)){
					info.setVersion(DESManager.getDesString(parser.nextText()));	//��ȡ�汾��
				} else if ("url".equals(tag)){
					info.setUrl(DESManager.getDesString(parser.nextText()));	//��ȡҪ���APK�ļ�
				} else if ("description".equals(tag)){
					info.setDescription(DESManager.getDesString(parser.nextText()));	//��ȡ���ļ�����Ϣ
				}
				
				/*if("version".equals(tag)){
					info.setVersion(parser.nextText());	//��ȡ�汾��
				} else if ("url".equals(tag)){
					info.setUrl(parser.nextText());	//��ȡҪ���APK�ļ�
				} else if ("description".equals(tag)){
					info.setDescription(parser.nextText());	//��ȡ���ļ�����Ϣ
				}*/
				
				break;
			case XmlPullParser.END_TAG:
                
                break;
			}
			type = parser.next();
		}
		is.close();
		return info;
	}
}
